# -*- coding: utf-8 -*-
"""
Created on Fri Aug 21 16:42:53 2020

@author: Administrator
"""


import sys
from PyQt5.QtWidgets import QApplication
from PyQt5 import QtWidgets, QtCore
from PyQt5.QtWidgets import QWidget, QFileDialog, QMessageBox
from ui import Ui_Form
import math
import os
import shutil
import csv
import datetime
from docx import Document
from docx.shared import Inches
from docx.oxml.ns import qn
from docx.oxml.shared import OxmlElement
from docx.oxml.shared import qn as qn2
from docx.shared import Pt
from docx.enum.style import WD_STYLE_TYPE
from docx.enum.text import WD_ALIGN_PARAGRAPH, WD_PARAGRAPH_ALIGNMENT
from docx.enum.table import WD_ALIGN_VERTICAL
from PyQt5 import QtWidgets, QtCore
from PyQt5.QtWidgets import QWidget, QFileDialog, QMessageBox
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
from my_canvas import MyCanvas
from utils import decode_data_from_txt
from data_structure import Height_DS, H_Speed_DS,V_Speed_DS,H_Stop_DS,V_Stop_DS,FuYang_DS,GunZhuan_DS,PianHangJiao_DS,V_Trace_DS,H_Trace_DS,H_Trace2_DS


"""
主界面类
"""
class MainWindow(QWidget, Ui_Form):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        # self.showMaximized() # 最大化窗口
        
        '''保存所有绘图及计算结果的数据结构'''
        self.height_ds = Height_DS()
        self.h_speed_ds = H_Speed_DS()
        self.v_speed_ds = V_Speed_DS()
        self.h_stop_ds = H_Stop_DS()
        self.v_stop_ds = V_Stop_DS()
        self.fuyang_ds = FuYang_DS()
        self.gunzhuan_ds = GunZhuan_DS()
        self.pianhang_ds = PianHangJiao_DS()
        self.v_trace_ds = V_Trace_DS()
        self.h_trace_ds = H_Trace_DS()
        self.h_trace2_ds = H_Trace2_DS()
        
        '''添加文件部分'''
        self.pushButton_chooseFile.clicked.connect(self.choose_file_function)    # 添加文件按钮绑定槽函数
        self.pushButton_deleteFile.clicked.connect(self.delete_file_function)    # 删除文件按钮绑定槽函数
        self.cwd = 'D:\\'    # 文件选择对话框默认路径设置
        self.files = []    # 维护（添加文件）的列表
        
        '''导入导出配置'''
        self.config_pushButton_output.clicked.connect(self.output_function)
        self.config_pushButton_input.clicked.connect(self.input_function)
        
        '''高度tab'''
        # 全局画布
        self.height_pushButton_plot_global.clicked.connect(self.height_draw_global_function)    # 绘制全局高度图按钮绑定槽函数
        self.height_canvas_global = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.height_toolbar_global = NavigationToolbar(self.height_canvas_global, self)    # 添加完整的toolbar
        self.height_verticalLayout_global.addWidget(self.height_canvas_global)    # 添加到垂直布局中
        self.height_verticalLayout_global.addWidget(self.height_toolbar_global)
        self.height_pushButton_excel_global.clicked.connect(self.height_global_to_excel)    # 保存全局数据到excel
        self.height_pushButton_clear_global.clicked.connect(self.height_canvas_global.canvas_clear)    # 清除绘图
        # 局部画布
        self.height_pushButton_plot_local.clicked.connect(self.height_draw_local_function)    # 绘制局部高度图
        self.height_canvas_local = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.height_toolbar_local = NavigationToolbar(self.height_canvas_local, self)    # 添加完整的toolbar
        self.height_verticalLayout_local.addWidget(self.height_canvas_local)    # 添加到垂直布局中
        self.height_verticalLayout_local.addWidget(self.height_toolbar_local)
        self.height_pushButton_excel_local.clicked.connect(self.height_local_to_excel)    # 保存局部数据到excel
        self.height_pushButton_clear_local.clicked.connect(self.height_canvas_local_clear)
        
        '''水平速度tab'''
        # 全局画布
        self.h_speed_pushButton_plot_global.clicked.connect(self.h_speed_draw_global_function)    # 绘制全局水平速度图
        self.h_speed_canvas_global = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.h_speed_toolbar_global = NavigationToolbar(self.h_speed_canvas_global, self)    # 添加完整的toolbar
        self.h_speed_verticalLayout_global.addWidget(self.h_speed_canvas_global)    # 添加到垂直布局中
        self.h_speed_verticalLayout_global.addWidget(self.h_speed_toolbar_global)
        self.h_speed_pushButton_excel_global.clicked.connect(self.h_speed_global_to_excel)    # 保存全局数据到excel
        self.h_speed_pushButton_clear_global.clicked.connect(self.h_speed_canvas_global.canvas_clear)
        # 往画布
        self.h_speed_pushButton_plot_wang.clicked.connect(self.h_speed_draw_wang_function)    # 绘制全局水平速度图
        self.h_speed_canvas_wang = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.h_speed_toolbar_wang = NavigationToolbar(self.h_speed_canvas_wang, self)    # 添加完整的toolbar
        self.h_speed_verticalLayout_wang.addWidget(self.h_speed_canvas_wang)    # 添加到垂直布局中
        self.h_speed_verticalLayout_wang.addWidget(self.h_speed_toolbar_wang)
        self.h_speed_pushButton_excel_wang.clicked.connect(self.h_speed_wang_to_excel)    # 保存全局数据到excel
        self.h_speed_pushButton_clear_wang.clicked.connect(self.h_speed_canvas_wang_clear)
        # 返画布
        self.h_speed_pushButton_plot_fan.clicked.connect(self.h_speed_draw_fan_function)    # 绘制全局水平速度图
        self.h_speed_canvas_fan = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.h_speed_toolbar_fan = NavigationToolbar(self.h_speed_canvas_fan, self)    # 添加完整的toolbar
        self.h_speed_verticalLayout_fan.addWidget(self.h_speed_canvas_fan)    # 添加到垂直布局中
        self.h_speed_verticalLayout_fan.addWidget(self.h_speed_toolbar_fan)
        self.h_speed_pushButton_excel_fan.clicked.connect(self.h_speed_fan_to_excel)    # 保存全局数据到excel
        self.h_speed_pushButton_clear_fan.clicked.connect(self.h_speed_canvas_fan_clear)
        # 计算往返速度的平均
        self.h_speed_pushButton_average_all.clicked.connect(self.h_speed_average_all_function)
        
        '''垂直速度tab'''
        # 全局画布
        self.v_speed_pushButton_plot_global.clicked.connect(self.v_speed_draw_global_function)    # 绘制全局水平速度图
        self.v_speed_canvas_global = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.v_speed_toolbar_global = NavigationToolbar(self.v_speed_canvas_global, self)    # 添加完整的toolbar
        self.v_speed_verticalLayout_global.addWidget(self.v_speed_canvas_global)    # 添加到垂直布局中
        self.v_speed_verticalLayout_global.addWidget(self.v_speed_toolbar_global)
        self.v_speed_pushButton_excel_global.clicked.connect(self.v_speed_global_to_excel)    # 保存全局数据到excel
        self.v_speed_pushButton_clear_global.clicked.connect(self.v_speed_canvas_global.canvas_clear)
        # 上升画布
        self.v_speed_pushButton_plot_shang.clicked.connect(self.v_speed_draw_shang_function)    # 绘制全局水平速度图
        self.v_speed_canvas_shang = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.v_speed_toolbar_shang = NavigationToolbar(self.v_speed_canvas_shang, self)    # 添加完整的toolbar
        self.v_speed_verticalLayout_shang.addWidget(self.v_speed_canvas_shang)    # 添加到垂直布局中
        self.v_speed_verticalLayout_shang.addWidget(self.v_speed_toolbar_shang)
        self.v_speed_pushButton_excel_shang.clicked.connect(self.v_speed_shang_to_excel)    # 保存全局数据到excel
        self.v_speed_pushButton_clear_shang.clicked.connect(self.v_speed_canvas_shang_clear)
        # 下降画布
        self.v_speed_pushButton_plot_xia.clicked.connect(self.v_speed_draw_xia_function)    # 绘制全局水平速度图
        self.v_speed_canvas_xia = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.v_speed_toolbar_xia = NavigationToolbar(self.v_speed_canvas_xia, self)    # 添加完整的toolbar
        self.v_speed_verticalLayout_xia.addWidget(self.v_speed_canvas_xia)    # 添加到垂直布局中
        self.v_speed_verticalLayout_xia.addWidget(self.v_speed_toolbar_xia)
        self.v_speed_pushButton_excel_xia.clicked.connect(self.v_speed_xia_to_excel)    # 保存全局数据到excel
        self.v_speed_pushButton_clear_xia.clicked.connect(self.v_speed_canvas_xia_clear)
        
        '''水平悬停tab'''
        # 全局画布
        self.h_stop_pushButton_plot_global.clicked.connect(self.h_stop_draw_global_function)    # 绘制全局水平悬停图
        self.h_stop_canvas_global = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.h_stop_toolbar_global = NavigationToolbar(self.h_stop_canvas_global, self)    # 添加完整的toolbar
        self.h_stop_verticalLayout_global.addWidget(self.h_stop_canvas_global)    # 添加到垂直布局中
        self.h_stop_verticalLayout_global.addWidget(self.h_stop_toolbar_global)
        self.h_stop_pushButton_excel_global.clicked.connect(self.h_stop_global_to_excel)    # 保存全局数据到excel
        self.h_stop_pushButton_clear_global.clicked.connect(self.h_stop_canvas_global.canvas_clear)
        # 局部画布
        self.h_stop_pushButton_plot_local.clicked.connect(self.h_stop_draw_local_function)    # 绘制局部高度图
        self.h_stop_canvas_local = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.h_stop_toolbar_local = NavigationToolbar(self.h_stop_canvas_local, self)    # 添加完整的toolbar
        self.h_stop_verticalLayout_local.addWidget(self.h_stop_canvas_local)    # 添加到垂直布局中
        self.h_stop_verticalLayout_local.addWidget(self.h_stop_toolbar_local)
        self.h_stop_pushButton_excel_local.clicked.connect(self.h_stop_local_to_excel)    # 保存局部数据到excel
        self.h_stop_pushButton_clear_local.clicked.connect(self.h_stop_canvas_local_clear)
        
        '''垂直悬停tab'''
        # 全局画布
        self.v_stop_pushButton_plot_global.clicked.connect(self.v_stop_draw_global_function)    # 绘制全局垂直悬停图
        self.v_stop_canvas_global = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.v_stop_toolbar_global = NavigationToolbar(self.v_stop_canvas_global, self)    # 添加完整的toolbar
        self.v_stop_verticalLayout_global.addWidget(self.v_stop_canvas_global)    # 添加到垂直布局中
        self.v_stop_verticalLayout_global.addWidget(self.v_stop_toolbar_global)
        self.v_stop_pushButton_excel_global.clicked.connect(self.v_stop_global_to_excel)    # 保存全局数据到excel
        self.v_stop_pushButton_clear_global.clicked.connect(self.v_stop_canvas_global.canvas_clear)
        # 局部画布
        self.v_stop_pushButton_plot_local.clicked.connect(self.v_stop_draw_local_function)    # 绘制局部垂直悬停图
        self.v_stop_canvas_local = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.v_stop_toolbar_local = NavigationToolbar(self.v_stop_canvas_local, self)    # 添加完整的toolbar
        self.v_stop_verticalLayout_local.addWidget(self.v_stop_canvas_local)    # 添加到垂直布局中
        self.v_stop_verticalLayout_local.addWidget(self.v_stop_toolbar_local)
        self.v_stop_pushButton_excel_local.clicked.connect(self.v_stop_local_to_excel)    # 保存局部数据到excel
        self.v_stop_pushButton_clear_local.clicked.connect(self.v_stop_canvas_local_clear)
        
        '''俯仰角tab'''
        # 全局画布
        self.fuyang_pushButton_plot_global.clicked.connect(self.fuyang_draw_global_function)    # 绘制全局俯仰角图按钮绑定槽函数
        self.fuyang_canvas_global = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.fuyang_toolbar_global = NavigationToolbar(self.fuyang_canvas_global, self)    # 添加完整的toolbar
        self.fuyang_verticalLayout_global.addWidget(self.fuyang_canvas_global)    # 添加到垂直布局中
        self.fuyang_verticalLayout_global.addWidget(self.fuyang_toolbar_global)
        self.fuyang_pushButton_excel_global.clicked.connect(self.fuyang_global_to_excel)    # 保存全局数据到excel
        self.fuyang_pushButton_clear_global.clicked.connect(self.fuyang_canvas_global.canvas_clear)
        # 局部画布
        self.fuyang_pushButton_plot_local.clicked.connect(self.fuyang_draw_local_function)    # 绘制局部俯仰角图
        self.fuyang_canvas_local = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.fuyang_toolbar_local = NavigationToolbar(self.fuyang_canvas_local, self)    # 添加完整的toolbar
        self.fuyang_verticalLayout_local.addWidget(self.fuyang_canvas_local)    # 添加到垂直布局中
        self.fuyang_verticalLayout_local.addWidget(self.fuyang_toolbar_local)
        self.fuyang_pushButton_excel_local.clicked.connect(self.fuyang_local_to_excel)    # 保存局部数据到excel
        self.fuyang_pushButton_clear_local.clicked.connect(self.fuyang_canvas_local_clear)
        
        '''滚转角tab'''
        # 全局画布
        self.gunzhuan_pushButton_plot_global.clicked.connect(self.gunzhuan_draw_global_function)    # 绘制全局滚转角图按钮绑定槽函数
        self.gunzhuan_canvas_global = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.gunzhuan_toolbar_global = NavigationToolbar(self.gunzhuan_canvas_global, self)    # 添加完整的toolbar
        self.gunzhuan_verticalLayout_global.addWidget(self.gunzhuan_canvas_global)    # 添加到垂直布局中
        self.gunzhuan_verticalLayout_global.addWidget(self.gunzhuan_toolbar_global)
        self.gunzhuan_pushButton_excel_global.clicked.connect(self.gunzhuan_global_to_excel)    # 保存全局数据到excel
        self.gunzhuan_pushButton_clear_global.clicked.connect(self.gunzhuan_canvas_global.canvas_clear)
        # 局部画布
        self.gunzhuan_pushButton_plot_local.clicked.connect(self.gunzhuan_draw_local_function)    # 绘制局部滚转角图
        self.gunzhuan_canvas_local = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.gunzhuan_toolbar_local = NavigationToolbar(self.gunzhuan_canvas_local, self)    # 添加完整的toolbar
        self.gunzhuan_verticalLayout_local.addWidget(self.gunzhuan_canvas_local)    # 添加到垂直布局中
        self.gunzhuan_verticalLayout_local.addWidget(self.gunzhuan_toolbar_local)
        self.gunzhuan_pushButton_excel_local.clicked.connect(self.gunzhuan_local_to_excel)    # 保存局部数据到excel
        self.gunzhuan_pushButton_clear_local.clicked.connect(self.gunzhuan_canvas_local_clear)
        
        '''偏航角tab'''
        # 全局画布
        self.pianhang_pushButton_plot_global.clicked.connect(self.pianhang_draw_global_function)    # 绘制全局偏航角图按钮绑定槽函数
        self.pianhang_canvas_global = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.pianhang_toolbar_global = NavigationToolbar(self.pianhang_canvas_global, self)    # 添加完整的toolbar
        self.pianhang_verticalLayout_global.addWidget(self.pianhang_canvas_global)    # 添加到垂直布局中
        self.pianhang_verticalLayout_global.addWidget(self.pianhang_toolbar_global)
        self.pianhang_pushButton_excel_global.clicked.connect(self.pianhang_global_to_excel)    # 保存全局数据到excel
        self.pianhang_pushButton_clear_global.clicked.connect(self.pianhang_canvas_global.canvas_clear)
        # 局部画布
        self.pianhang_pushButton_plot_local.clicked.connect(self.pianhang_draw_local_function)    # 绘制偏航滚转角图
        self.pianhang_canvas_local = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.pianhang_toolbar_local = NavigationToolbar(self.pianhang_canvas_local, self)    # 添加完整的toolbar
        self.pianhang_verticalLayout_local.addWidget(self.pianhang_canvas_local)    # 添加到垂直布局中
        self.pianhang_verticalLayout_local.addWidget(self.pianhang_toolbar_local)
        self.pianhang_pushButton_excel_local.clicked.connect(self.pianhang_local_to_excel)    # 保存局部数据到excel
        self.pianhang_pushButton_clear_local.clicked.connect(self.pianhang_canvas_local_clear)
        
        '''航迹垂直精度tab'''
        # 全局画布
        self.v_trace_pushButton_plot_global.clicked.connect(self.v_trace_draw_global_function)    # 绘制全局航迹垂直精度图按钮绑定槽函数
        self.v_trace_canvas_global = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.v_trace_toolbar_global = NavigationToolbar(self.v_trace_canvas_global, self)    # 添加完整的toolbar
        self.v_trace_verticalLayout_global.addWidget(self.v_trace_canvas_global)    # 添加到垂直布局中
        self.v_trace_verticalLayout_global.addWidget(self.v_trace_toolbar_global)
        self.v_trace_pushButton_clear_global.clicked.connect(self.v_trace_canvas_global.canvas_clear)
        # 局部画布
        self.v_trace_pushButton_plot_local.clicked.connect(self.v_trace_draw_local_function)    # 绘制局部航迹垂直精度图
        self.v_trace_canvas_local = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.v_trace_toolbar_local = NavigationToolbar(self.v_trace_canvas_local, self)    # 添加完整的toolbar
        self.v_trace_verticalLayout_local.addWidget(self.v_trace_canvas_local)    # 添加到垂直布局中
        self.v_trace_verticalLayout_local.addWidget(self.v_trace_toolbar_local)
        self.v_trace_pushButton_excel_local.clicked.connect(self.v_trace_local_to_excel)    # 保存局部数据到excel
        self.v_trace_pushButton_clear_local.clicked.connect(self.v_trace_canvas_local_clear)
        
        '''航迹水平精度tab'''
        # 全局画布
        self.h_trace_pushButton_plot_global.clicked.connect(self.h_trace_draw_global_function)    # 绘制全局航迹水平精度图按钮绑定槽函数
        self.h_trace_canvas_global = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.h_trace_toolbar_global = NavigationToolbar(self.h_trace_canvas_global, self)    # 添加完整的toolbar
        self.h_trace_verticalLayout_global.addWidget(self.h_trace_canvas_global)    # 添加到垂直布局中
        self.h_trace_verticalLayout_global.addWidget(self.h_trace_toolbar_global)
        self.h_trace_pushButton_clear_global.clicked.connect(self.h_trace_canvas_global.canvas_clear)
        # 局部画布
        self.h_trace_pushButton_plot_local.clicked.connect(self.h_trace_draw_local_function)    # 绘制局部航迹水平精度图
        self.h_trace_canvas_local = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.h_trace_toolbar_local = NavigationToolbar(self.h_trace_canvas_local, self)    # 添加完整的toolbar
        self.h_trace_verticalLayout_local.addWidget(self.h_trace_canvas_local)    # 添加到垂直布局中
        self.h_trace_verticalLayout_local.addWidget(self.h_trace_toolbar_local)
        self.h_trace_pushButton_excel_local.clicked.connect(self.h_trace_local_to_excel)    # 保存局部数据到excel
        self.h_trace_pushButton_clear_local.clicked.connect(self.h_trace_canvas_local_clear)
        
        '''航迹水平精度（输入起终点经纬度）tab'''
        # 全局画布
        self.h_trace2_pushButton_plot_global.clicked.connect(self.h_trace2_draw_global_function)    # 绘制全局航迹水平精度图按钮绑定槽函数
        self.h_trace2_canvas_global = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.h_trace2_toolbar_global = NavigationToolbar(self.h_trace2_canvas_global, self)    # 添加完整的toolbar
        self.h_trace2_verticalLayout_global.addWidget(self.h_trace2_canvas_global)    # 添加到垂直布局中
        self.h_trace2_verticalLayout_global.addWidget(self.h_trace2_toolbar_global)
        self.h_trace2_pushButton_clear_global.clicked.connect(self.h_trace2_canvas_global.canvas_clear)
        # 局部画布
        self.h_trace2_pushButton_plot_local.clicked.connect(self.h_trace2_draw_local_function)    # 绘制局部航迹水平精度图
        self.h_trace2_canvas_local = MyCanvas(self, width=5, height=4, dpi=100)    # 添加画布
        self.h_trace2_toolbar_local = NavigationToolbar(self.h_trace2_canvas_local, self)    # 添加完整的toolbar
        self.h_trace2_verticalLayout_local.addWidget(self.h_trace2_canvas_local)    # 添加到垂直布局中
        self.h_trace2_verticalLayout_local.addWidget(self.h_trace2_toolbar_local)
        self.h_trace2_pushButton_excel_local.clicked.connect(self.h_trace2_local_to_excel)    # 保存局部数据到excel
        self.h_trace2_pushButton_clear_local.clicked.connect(self.h_trace2_canvas_local_clear)
        
        '''word报告tab'''
        self.report_pushButton_generate_report.clicked.connect(self.report_generate_report)    # 生成报告槽函数
        
        
    '''
    添加文件按钮绑定的槽函数
    '''    
    def choose_file_function(self):
        # fileName_choose是文件的路径，filetype是文件类型
        fileName_choose, filetype = QFileDialog.getOpenFileName(self,  
                                    "选取文件",  
                                    self.cwd, # 起始路径 
                                    "Text Files (*.txt)")   # 设置文件扩展名过滤,用双分号间隔
        if fileName_choose == '':
            return
        if fileName_choose not in self.files:
            self.files.append(fileName_choose)
            self.tableWidget_select.setRowCount(len(self.files))    # 要先设置行数，才能显示行
            self.tableWidget_select.setVerticalHeaderLabels(self.files)    # 设置行
            columnCount = self.tableWidget_select.columnCount()    # 表格的列数
            for j in range(0,columnCount):
                check = QtWidgets.QTableWidgetItem()
                check.setCheckState(QtCore.Qt.Unchecked)	#把checkBox设为未选中状态
                self.tableWidget_select.setItem(len(self.files)-1, j, check)    #在(x,y)添加checkBox
            # 如果获取(x,y)的状态 self.tableWidget.item(x,y).checkState()
        else:
            msg_box = QMessageBox(QMessageBox.Warning, '警告', '该文件已经选取过！')
            msg_box.exec_()
            
    '''删除文件按钮绑定的槽函数'''    
    def delete_file_function(self):
        current_row = self.tableWidget_select.currentRow()    # 获取当前选定要删除的行
        if current_row < 0:    # 未选中时点击删除 是没有用的
            return
        self.files.remove(self.files[current_row])    # 删除文件名列表中对应的文件
        self.tableWidget_select.removeRow(current_row)    # 删除该行
        
    '''公共功能：判断勾选情况'''
    def is_checked_OK(self, index, name):
        # index 是第几列， name是要警告的标签名
        checked_count = 0
        for i in range(len(self.files)):
            if self.tableWidget_select.item(i,index).checkState() == 2:
                checked_count += 1
                selected_file = self.files[i]
        if checked_count == 0:    # 未勾选文件
            msg_box = QMessageBox(QMessageBox.Warning, '警告', '未勾选文件！（'+name+'）')
            msg_box.exec_()
            return False, None
        elif checked_count >= 2:    # 勾选的文件数量超过1个
            msg_box = QMessageBox(QMessageBox.Warning, '警告', '勾选的文件数量超过1个！（'+name+'）')
            msg_box.exec_()
            return False, None
        elif checked_count == 1:    # 勾选一个时返回True和对应的文件名
            return True, selected_file
        
    '''
    公共功能：弹出保存到excel的窗口
    '''
    def save_to_excel(self):
        fileName_choose, filetype = QFileDialog.getSaveFileName(self,  
                                    "Excel文件保存",  
                                    self.cwd, # 起始路径 
                                    "Excel Files (*.csv)")
        return fileName_choose
    
    '''公共功能：弹出成功的窗口'''
    def success(self):
        msg_box = QMessageBox(QMessageBox.Warning, '信息', '操作成功！')
        msg_box.exec_()
        
    '''绘制全局高度图像的槽函数'''
    def height_draw_global_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(0, '高度')
        if bool_is_ok:
            X, Y = decode_data_from_txt(selected_file, '高度')
            self.height_ds.X_global = X
            self.height_ds.Y_global = Y
            self.height_canvas_global.start_static_plot('高度分析（全局）','时间（时：分：秒）','高度（米）',X,Y)
        
    '''绘制局部高度图像的槽函数'''
    def height_draw_local_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(0, '高度')
        if bool_is_ok == False:
            return
        if self.height_lineEdit_starttime.text() =='' or self.height_lineEdit_endtime.text() =='':
            msg_box = QMessageBox(QMessageBox.Warning, '警告', '起始时刻和终止时刻都不能为空！')
            msg_box.exec_()
            return
        if bool_is_ok:
            X, Y = decode_data_from_txt(selected_file, '高度', self.height_lineEdit_starttime.text(), self.height_lineEdit_endtime.text())
            self.height_ds.X_local = X
            self.height_ds.Y_local = Y
            self.height_ds.cal_ave_height()
            self.height_label_average_height.setText(str(round(self.height_ds.ave_height,3))+'米')
            self.height_canvas_local.start_static_plot('高度分析（局部）','时间（时：分：秒）','高度（米）',X,Y)
            try:
                if self.height_lineEdit_shangxian.text() != '' and self.height_lineEdit_xiaxian.text() != '':
                    if self.height_ds.ave_height <= float(self.height_lineEdit_shangxian.text()) and self.height_ds.ave_height >= float(self.height_lineEdit_xiaxian.text()):
                        self.height_label_jieguo.setText('符合')
                    else:
                        self.height_label_jieguo.setText('不符合')
            except:
                msg_box = QMessageBox(QMessageBox.Warning, '警告', '上下限填写错误！')
                msg_box.exec_()
    
    '''保存全局高度数据到excel'''
    def height_global_to_excel(self):
        path = self.save_to_excel()
        if path == '':
            return
        X = self.height_ds.X_global
        Y = self.height_ds.Y_global
        with open(path,'w',encoding='utf-8-sig',newline='') as f:
            csv_writer = csv.writer(f)
            csv_writer.writerow(["时间","高度"])
            for i in range(0,len(X)):
                csv_writer.writerow([X[i].strftime("%H:%M:%S"),Y[i]])
        self.success()
        
    '''保存局部高度数据到excel'''
    def height_local_to_excel(self):
        path = self.save_to_excel()
        if path == '':
            return
        X = self.height_ds.X_local
        Y = self.height_ds.Y_local
        with open(path,'w',encoding='utf-8-sig',newline='') as f:
            csv_writer = csv.writer(f)
            csv_writer.writerow(["时间","高度"])
            for i in range(0,len(X)):
                csv_writer.writerow([X[i].strftime("%H:%M:%S"),Y[i]])
        self.success()
    
    '''清除画布及编辑框'''
    def height_canvas_local_clear(self):
        self.height_canvas_local.canvas_clear()
        self.height_lineEdit_shangxian.setText('')
        self.height_lineEdit_xiaxian.setText('')
        self.height_lineEdit_starttime.setText('')
        self.height_lineEdit_endtime.setText('')
        self.height_label_average_height.setText('')
        self.height_label_jieguo.setText('')
        
    '''绘制全局水平速度图像的槽函数'''
    def h_speed_draw_global_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(1, '水平速度')
        if bool_is_ok:
            X, Y = decode_data_from_txt(selected_file, '水平速度')
            self.h_speed_ds.X_global = X
            self.h_speed_ds.Y_global = Y
            self.h_speed_canvas_global.start_static_plot('水平速度分析（全局）','时间（时：分：秒）','速度（米/秒）',X,Y)
    
    '''保存全局水平速度数据到excel'''
    def h_speed_global_to_excel(self):
        path = self.save_to_excel()
        if path == '':
            return
        X = self.h_speed_ds.X_global
        Y = self.h_speed_ds.Y_global
        with open(path,'w',encoding='utf-8-sig',newline='') as f:
            csv_writer = csv.writer(f)
            csv_writer.writerow(["时间","水平速度"])
            for i in range(0,len(X)):
                csv_writer.writerow([X[i].strftime("%H:%M:%S"),Y[i]])
        self.success()
        
    '''绘制往水平速度图像的槽函数'''
    def h_speed_draw_wang_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(1, '水平速度')
        if bool_is_ok == False:
            return
        if self.h_speed_lineEdit_starttime_wang.text() =='' or self.h_speed_lineEdit_endtime_wang.text() =='':
            msg_box = QMessageBox(QMessageBox.Warning, '警告', '往起始和往终止时刻都不能为空！')
            msg_box.exec_()
            return
        if bool_is_ok:
            X, Y = decode_data_from_txt(selected_file, '水平速度', self.h_speed_lineEdit_starttime_wang.text(), self.h_speed_lineEdit_endtime_wang.text())
            self.h_speed_ds.X_wang = X
            self.h_speed_ds.Y_wang = Y
            self.h_speed_ds.cal_ave_wang()
            self.h_speed_label_wang.setText(str(round(self.h_speed_ds.ave_wang,3))+'米/秒')
            self.h_speed_canvas_wang.start_static_plot('水平速度分析（往）','时间（时：分：秒）','速度（米/秒）',X,Y)
                  
    '''保存往水平速度数据到excel'''
    def h_speed_wang_to_excel(self):
        path = self.save_to_excel()
        if path == '':
            return
        X = self.h_speed_ds.X_wang
        Y = self.h_speed_ds.Y_wang
        with open(path,'w',encoding='utf-8-sig',newline='') as f:
            csv_writer = csv.writer(f)
            csv_writer.writerow(["时间","水平速度"])
            for i in range(0,len(X)):
                csv_writer.writerow([X[i].strftime("%H:%M:%S"),Y[i]])
        self.success()   
    
    '''清除画布及编辑框'''
    def h_speed_canvas_wang_clear(self):
        self.h_speed_canvas_wang.canvas_clear()
        self.h_speed_lineEdit_shangxian.setText('')
        self.h_speed_lineEdit_xiaxian.setText('')
        self.h_speed_lineEdit_starttime_wang.setText('')
        self.h_speed_lineEdit_endtime_wang.setText('')
        self.h_speed_label_wang.setText('')
        self.h_speed_label_all.setText('')
        self.h_speed_label_jieguo_global.setText('')
        
    '''绘制返水平速度图像的槽函数'''
    def h_speed_draw_fan_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(1, '水平速度')
        if bool_is_ok == False:
            return
        if self.h_speed_lineEdit_starttime_fan.text() =='' or self.h_speed_lineEdit_endtime_fan.text() =='':
            msg_box = QMessageBox(QMessageBox.Warning, '警告', '返起始和返终止时刻都不能为空！')
            msg_box.exec_()
            return
        if bool_is_ok:
            X, Y = decode_data_from_txt(selected_file, '水平速度', self.h_speed_lineEdit_starttime_fan.text(), self.h_speed_lineEdit_endtime_fan.text())
            self.h_speed_ds.X_fan = X
            self.h_speed_ds.Y_fan = Y
            self.h_speed_ds.cal_ave_fan()
            self.h_speed_label_fan.setText(str(round(self.h_speed_ds.ave_fan,3))+'米/秒')
            self.h_speed_canvas_fan.start_static_plot('水平速度分析（返）','时间（时：分：秒）','速度（米/秒）',X,Y)
            
    '''保存返水平速度数据到excel'''
    def h_speed_fan_to_excel(self):
        path = self.save_to_excel()
        if path == '':
            return
        X = self.h_speed_ds.X_fan
        Y = self.h_speed_ds.Y_fan
        with open(path,'w',encoding='utf-8-sig',newline='') as f:
            csv_writer = csv.writer(f)
            csv_writer.writerow(["时间","水平速度"])
            for i in range(0,len(X)):
                csv_writer.writerow([X[i].strftime("%H:%M:%S"),Y[i]])
        self.success()
        
    '''清除画布及编辑框'''
    def h_speed_canvas_fan_clear(self):
        self.h_speed_canvas_fan.canvas_clear()
        self.h_speed_lineEdit_shangxian.setText('')
        self.h_speed_lineEdit_xiaxian.setText('')
        self.h_speed_lineEdit_starttime_fan.setText('')
        self.h_speed_lineEdit_endtime_fan.setText('')
        self.h_speed_label_fan.setText('')
        self.h_speed_label_all.setText('')
        self.h_speed_label_jieguo_global.setText('')
    
    '''计算往返水平速度的平均并显示'''
    def h_speed_average_all_function(self):
        try:
            self.h_speed_ds.cal_ave_global()
            self.h_speed_label_all.setText(str(round(self.h_speed_ds.ave_global,3))+'米/秒')
            if self.h_speed_ds.ave_global <= float(self.h_speed_lineEdit_shangxian.text()) and self.h_speed_ds.ave_global >= float(self.h_speed_lineEdit_xiaxian.text()):
                    self.h_speed_label_jieguo_global.setText('符合')
            else:
                self.h_speed_label_jieguo_global.setText('不符合')
        except:
            msg_box = QMessageBox(QMessageBox.Warning, '警告', '请先计算往速度和返速度，或者上下限未填写！')
            msg_box.exec_()
        
    '''绘制全局垂直速度图像的槽函数'''
    def v_speed_draw_global_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(2, '垂直速度')
        if bool_is_ok:
            X, Y = decode_data_from_txt(selected_file, '垂直速度')
            self.v_speed_ds.X_global = X
            self.v_speed_ds.Y_global = Y
            self.v_speed_canvas_global.start_static_plot('垂直速度分析（全局）','时间（时：分：秒）','速度（米/秒）',X,Y)
    
    '''保存全局垂直速度数据到excel'''
    def v_speed_global_to_excel(self):
        path = self.save_to_excel()
        if path == '':
            return
        X = self.v_speed_ds.X_global
        Y = self.v_speed_ds.Y_global
        with open(path,'w',encoding='utf-8-sig',newline='') as f:
            csv_writer = csv.writer(f)
            csv_writer.writerow(["时间","垂直速度"])
            for i in range(0,len(X)):
                csv_writer.writerow([X[i].strftime("%H:%M:%S"),Y[i]])
        self.success()
        
    '''绘制上升速度图像的槽函数'''
    def v_speed_draw_shang_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(2, '垂直速度')
        if bool_is_ok == False:
            return
        if self.v_speed_lineEdit_starttime_shang.text() =='' or self.v_speed_lineEdit_endtime_shang.text() =='':
            msg_box = QMessageBox(QMessageBox.Warning, '警告', '上升起始和上升终止时刻都不能为空！')
            msg_box.exec_()
            return
        if bool_is_ok:
            X, Y = decode_data_from_txt(selected_file, '垂直速度', self.v_speed_lineEdit_starttime_shang.text(), self.v_speed_lineEdit_endtime_shang.text())
            self.v_speed_ds.X_shang = X
            self.v_speed_ds.Y_shang = Y
            self.v_speed_ds.cal_ave_shang()
            self.v_speed_label_shang.setText(str(round(self.v_speed_ds.ave_shang,3))+'米/秒')
            self.v_speed_canvas_shang.start_static_plot('上升速度分析','时间（时：分：秒）','速度（米/秒）',X,Y)
            try:
                if self.v_speed_lineEdit_shang_shangxian.text() != '' and self.v_speed_lineEdit_shang_xiaxian.text() != '':
                    if self.v_speed_ds.ave_shang <= float(self.v_speed_lineEdit_shang_shangxian.text()) and self.v_speed_ds.ave_shang >= float(self.v_speed_lineEdit_shang_xiaxian.text()):
                        self.v_speed_label_jieguo_shang.setText('符合')
                    else:
                        self.v_speed_label_jieguo_shang.setText('不符合')
            except:
                msg_box = QMessageBox(QMessageBox.Warning, '警告', '上下限填写错误！')
                msg_box.exec_()
            
    '''保存上升速度数据到excel'''
    def v_speed_shang_to_excel(self):
        path = self.save_to_excel()
        if path == '':
            return
        X = self.v_speed_ds.X_shang
        Y = self.v_speed_ds.Y_shang
        with open(path,'w',encoding='utf-8-sig',newline='') as f:
            csv_writer = csv.writer(f)
            csv_writer.writerow(["时间","上升速度"])
            for i in range(0,len(X)):
                csv_writer.writerow([X[i].strftime("%H:%M:%S"),Y[i]])
        self.success()
        
    '''清除画布及编辑框'''
    def v_speed_canvas_shang_clear(self):
        self.v_speed_canvas_shang.canvas_clear()
        self.v_speed_lineEdit_shang_shangxian.setText('')
        self.v_speed_lineEdit_shang_xiaxian.setText('')
        self.v_speed_lineEdit_starttime_shang.setText('')
        self.v_speed_lineEdit_endtime_shang.setText('')
        self.v_speed_label_shang.setText('')
        self.v_speed_label_jieguo_shang.setText('')
    
    '''绘制下降速度图像的槽函数'''
    def v_speed_draw_xia_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(2, '垂直速度')
        if bool_is_ok == False:
            return
        if self.v_speed_lineEdit_starttime_xia.text() =='' or self.v_speed_lineEdit_endtime_xia.text() =='':
            msg_box = QMessageBox(QMessageBox.Warning, '警告', '下降起始和下降终止时刻都不能为空！')
            msg_box.exec_()
            return
        if bool_is_ok:
            X, Y = decode_data_from_txt(selected_file, '垂直速度', self.v_speed_lineEdit_starttime_xia.text(), self.v_speed_lineEdit_endtime_xia.text())
            self.v_speed_ds.X_xia = X
            self.v_speed_ds.Y_xia = Y
            self.v_speed_ds.cal_ave_xia()
            self.v_speed_label_xia.setText(str(round(self.v_speed_ds.ave_xia,3))+'米/秒')
            self.v_speed_canvas_xia.start_static_plot('下降速度分析','时间（时：分：秒）','速度（米/秒）',X,Y)
            try:
                if self.v_speed_lineEdit_xia_shangxian.text() != '' and self.v_speed_lineEdit_xia_xiaxian.text() != '':
                    if self.v_speed_ds.ave_xia <= float(self.v_speed_lineEdit_xia_shangxian.text()) and self.v_speed_ds.ave_xia >= float(self.v_speed_lineEdit_xia_xiaxian.text()):
                        self.v_speed_label_jieguo_xia.setText('符合')
                    else:
                        self.v_speed_label_jieguo_xia.setText('不符合')
            except:
                msg_box = QMessageBox(QMessageBox.Warning, '警告', '上下限填写错误！')
                msg_box.exec_()
            
    '''保存下降速度数据到excel'''
    def v_speed_xia_to_excel(self):
        path = self.save_to_excel()
        if path == '':
            return
        X = self.v_speed_ds.X_xia
        Y = self.v_speed_ds.Y_xia
        with open(path,'w',encoding='utf-8-sig',newline='') as f:
            csv_writer = csv.writer(f)
            csv_writer.writerow(["时间","下降速度"])
            for i in range(0,len(X)):
                csv_writer.writerow([X[i].strftime("%H:%M:%S"),Y[i]])
        self.success() 
        
    '''清除画布及编辑框'''
    def v_speed_canvas_xia_clear(self):
        self.v_speed_canvas_xia.canvas_clear()
        self.v_speed_lineEdit_xia_shangxian.setText('')
        self.v_speed_lineEdit_xia_xiaxian.setText('')
        self.v_speed_lineEdit_starttime_xia.setText('')
        self.v_speed_lineEdit_endtime_xia.setText('')
        self.v_speed_label_xia.setText('')
        self.v_speed_label_jieguo_xia.setText('')
        
    '''绘制全局水平悬停图像的槽函数'''
    def h_stop_draw_global_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(3, '水平悬停')
        if bool_is_ok:
            X, Y = decode_data_from_txt(selected_file, '水平悬停')
            self.h_stop_ds.X_global = X
            self.h_stop_ds.Y_global = Y
            self.h_stop_canvas_global.start_static_plot('水平悬停（全局）','时间（时：分：秒）','水平悬停误差（米）',X,Y)
    
    '''保存全局水平悬停数据到excel'''
    def h_stop_global_to_excel(self):
        path = self.save_to_excel()
        if path == '':
            return
        X = self.h_stop_ds.X_global
        Y = self.h_stop_ds.Y_global
        with open(path,'w',encoding='utf-8-sig',newline='') as f:
            csv_writer = csv.writer(f)
            csv_writer.writerow(["时间","水平悬停精度（全局）"])
            for i in range(0,len(X)):
                csv_writer.writerow([X[i].strftime("%H:%M:%S"),Y[i]])
        self.success()    
    
    '''绘制局部水平悬停数据的槽函数'''
    def h_stop_draw_local_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(3, '水平悬停')
        if bool_is_ok == False:
            return
        if self.h_stop_lineEdit_starttime.text() =='' or self.h_stop_lineEdit_endtime.text() =='':
            msg_box = QMessageBox(QMessageBox.Warning, '警告', '起始时刻和终止时刻都不能为空！')
            msg_box.exec_()
            return
        if bool_is_ok:
            X, Y = decode_data_from_txt(selected_file, '水平悬停', self.h_stop_lineEdit_starttime.text(), self.h_stop_lineEdit_endtime.text())
            self.h_stop_ds.X_local = X
            self.h_stop_ds.Y_local = Y
            self.h_stop_ds.cal_max_diff()
            self.h_stop_label_max_diff.setText(str(round(self.h_stop_ds.max_diff,3))+'米')
            self.h_stop_canvas_local.start_static_plot('水平悬停（局部）','时间（时：分：秒）','水平悬停误差（米）',X,Y)
            try:
                if self.h_stop_lineEdit_shangxian.text() != '' and self.h_stop_lineEdit_xiaxian.text() != '':
                    if self.h_stop_ds.max_diff <= float(self.h_stop_lineEdit_shangxian.text()) and self.h_stop_ds.max_diff >= float(self.h_stop_lineEdit_xiaxian.text()):
                        self.h_stop_label_jieguo.setText('符合')
                    else:
                        self.h_stop_label_jieguo.setText('不符合')
            except:
                msg_box = QMessageBox(QMessageBox.Warning, '警告', '上下限填写错误！')
                msg_box.exec_()
    
    '''保存局部水平悬停数据到excel'''
    def h_stop_local_to_excel(self):
        path = self.save_to_excel()
        if path == '':
            return
        X = self.h_stop_ds.X_local
        Y = self.h_stop_ds.Y_local
        with open(path,'w',encoding='utf-8-sig',newline='') as f:
            csv_writer = csv.writer(f)
            csv_writer.writerow(["时间","水平悬停精度（局部）"])
            for i in range(0,len(X)):
                csv_writer.writerow([X[i].strftime("%H:%M:%S"),Y[i]])
        self.success()
        
    '''清除画布及编辑框'''
    def h_stop_canvas_local_clear(self):
        self.h_stop_canvas_local.canvas_clear()
        self.h_stop_lineEdit_shangxian.setText('')
        self.h_stop_lineEdit_xiaxian.setText('')
        self.h_stop_lineEdit_starttime.setText('')
        self.h_stop_lineEdit_endtime.setText('')
        self.h_stop_label_max_diff.setText('')
        self.h_stop_label_jieguo.setText('')
        
    '''绘制全局垂直悬停图像的槽函数'''
    def v_stop_draw_global_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(4, '垂直悬停')
        if bool_is_ok:
            X, Y = decode_data_from_txt(selected_file, '垂直悬停')
            self.v_stop_ds.X_global = X
            self.v_stop_ds.Y_global = Y
            self.v_stop_canvas_global.start_static_plot('垂直悬停（全局）','时间（时：分：秒）','垂直悬停误差（米）',X,Y)
    
    '''保存全局垂直悬停数据到excel'''
    def v_stop_global_to_excel(self):
        path = self.save_to_excel()
        if path == '':
            return
        X = self.v_stop_ds.X_global
        Y = self.v_stop_ds.Y_global
        with open(path,'w',encoding='utf-8-sig',newline='') as f:
            csv_writer = csv.writer(f)
            csv_writer.writerow(["时间","垂直悬停精度（全局）"])
            for i in range(0,len(X)):
                csv_writer.writerow([X[i].strftime("%H:%M:%S"),Y[i]])
        self.success()    
    
    '''绘制局部垂直悬停数据的槽函数'''
    def v_stop_draw_local_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(4, '垂直悬停')
        if bool_is_ok == False:
            return
        if self.v_stop_lineEdit_starttime.text() =='' or self.v_stop_lineEdit_endtime.text() =='':
            msg_box = QMessageBox(QMessageBox.Warning, '警告', '起始时刻和终止时刻都不能为空！')
            msg_box.exec_()
            return
        if bool_is_ok:
            X, Y = decode_data_from_txt(selected_file, '垂直悬停', self.v_stop_lineEdit_starttime.text(), self.v_stop_lineEdit_endtime.text())
            self.v_stop_ds.X_local = X
            self.v_stop_ds.Y_local = Y
            self.v_stop_ds.cal_max_diff()
            self.v_stop_label_max_diff.setText(str(round(self.v_stop_ds.max_diff,3))+'米')
            self.v_stop_canvas_local.start_static_plot('垂直悬停（局部）','时间（时：分：秒）','垂直悬停误差（米）',X,Y)
            try:
                if self.v_stop_lineEdit_shangxian.text() != '' and self.v_stop_lineEdit_xiaxian.text() != '':
                    if self.v_stop_ds.max_diff <= float(self.v_stop_lineEdit_shangxian.text()) and self.v_stop_ds.max_diff >= float(self.v_stop_lineEdit_xiaxian.text()):
                        self.v_stop_label_jieguo.setText('符合')
                    else:
                        self.v_stop_label_jieguo.setText('不符合')
            except:
                msg_box = QMessageBox(QMessageBox.Warning, '警告', '上下限填写错误！')
                msg_box.exec_()
                
    '''保存局部垂直悬停数据到excel'''
    def v_stop_local_to_excel(self):
        path = self.save_to_excel()
        if path == '':
            return
        X = self.v_stop_ds.X_local
        Y = self.v_stop_ds.Y_local
        with open(path,'w',encoding='utf-8-sig',newline='') as f:
            csv_writer = csv.writer(f)
            csv_writer.writerow(["时间","垂直悬停精度（局部）"])
            for i in range(0,len(X)):
                csv_writer.writerow([X[i].strftime("%H:%M:%S"),Y[i]])
        self.success()
    
    '''清除画布及编辑框'''
    def v_stop_canvas_local_clear(self):
        self.v_stop_canvas_local.canvas_clear()
        self.v_stop_lineEdit_shangxian.setText('')
        self.v_stop_lineEdit_xiaxian.setText('')
        self.v_stop_lineEdit_starttime.setText('')
        self.v_stop_lineEdit_endtime.setText('')
        self.v_stop_label_max_diff.setText('')
        self.v_stop_label_jieguo.setText('')
    
    '''绘制全局俯仰角图像的槽函数'''
    def fuyang_draw_global_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(7, '俯仰角')
        if bool_is_ok:
            X, Y = decode_data_from_txt(selected_file, '俯仰角')
            self.fuyang_ds.X_global = X
            self.fuyang_ds.Y_global = Y
            self.fuyang_canvas_global.start_static_plot('俯仰角（全局）','时间（时：分：秒）','俯仰角（°）',X,Y)
    
    '''保存全局俯仰角数据到excel'''
    def fuyang_global_to_excel(self):
        path = self.save_to_excel()
        if path == '':
            return
        X = self.fuyang_ds.X_global
        Y = self.fuyang_ds.Y_global
        with open(path,'w',encoding='utf-8-sig',newline='') as f:
            csv_writer = csv.writer(f)
            csv_writer.writerow(["时间","俯仰角（全局）"])
            for i in range(0,len(X)):
                csv_writer.writerow([X[i].strftime("%H:%M:%S"),Y[i]])
        self.success()    
    
    '''绘制局部俯仰角数据的槽函数'''
    def fuyang_draw_local_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(7, '俯仰角')
        if bool_is_ok == False:
            return
        if self.fuyang_lineEdit_starttime.text() =='' or self.fuyang_lineEdit_endtime.text() =='':
            msg_box = QMessageBox(QMessageBox.Warning, '警告', '起始时刻和终止时刻都不能为空！')
            msg_box.exec_()
            return
        if bool_is_ok:
            X, Y = decode_data_from_txt(selected_file, '俯仰角', self.fuyang_lineEdit_starttime.text(), self.fuyang_lineEdit_endtime.text())
            self.fuyang_ds.X_local = X
            self.fuyang_ds.Y_local = Y
            self.fuyang_ds.cal_ave_edge()
            self.fuyang_label_average_edge.setText(str(round(self.fuyang_ds.ave_edge,3))+'°')
            self.fuyang_canvas_local.start_static_plot('俯仰角（局部）','时间（时：分：秒）','俯仰角偏差（°）',X,Y)
            try:
                if self.fuyang_lineEdit_shangxian.text() != '' and self.fuyang_lineEdit_xiaxian.text() != '':
                    if self.fuyang_ds.ave_edge <= float(self.fuyang_lineEdit_shangxian.text()) and self.fuyang_ds.ave_edge >= float(self.fuyang_lineEdit_xiaxian.text()):
                        self.fuyang_label_jieguo.setText('符合')
                    else:
                        self.fuyang_label_jieguo.setText('不符合')
            except:
                msg_box = QMessageBox(QMessageBox.Warning, '警告', '上下限填写错误！')
                msg_box.exec_()
            
                
    '''保存局部俯仰角数据到excel'''
    def fuyang_local_to_excel(self):
        path = self.save_to_excel()
        if path == '':
            return
        X = self.fuyang_ds.X_local
        Y = self.fuyang_ds.Y_local
        with open(path,'w',encoding='utf-8-sig',newline='') as f:
            csv_writer = csv.writer(f)
            csv_writer.writerow(["时间","俯仰角（局部）"])
            for i in range(0,len(X)):
                csv_writer.writerow([X[i].strftime("%H:%M:%S"),Y[i]])
        self.success()
        
    '''清除画布及编辑框'''
    def fuyang_canvas_local_clear(self):
        self.fuyang_canvas_local.canvas_clear()
        self.fuyang_lineEdit_shangxian.setText('')
        self.fuyang_lineEdit_xiaxian.setText('')
        self.fuyang_lineEdit_starttime.setText('')
        self.fuyang_lineEdit_endtime.setText('')
        self.fuyang_label_average_edge.setText('')
        self.fuyang_label_jieguo.setText('')
        
    '''绘制全局滚转角图像的槽函数'''
    def gunzhuan_draw_global_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(8, '滚转角')
        if bool_is_ok:
            X, Y = decode_data_from_txt(selected_file, '滚转角')
            self.gunzhuan_ds.X_global = X
            self.gunzhuan_ds.Y_global = Y
            self.gunzhuan_canvas_global.start_static_plot('滚转角（全局）','时间（时：分：秒）','滚转角（°）',X,Y)
    
    '''保存全局滚转角数据到excel'''
    def gunzhuan_global_to_excel(self):
        path = self.save_to_excel()
        if path == '':
            return
        X = self.gunzhuan_ds.X_global
        Y = self.gunzhuan_ds.Y_global
        with open(path,'w',encoding='utf-8-sig',newline='') as f:
            csv_writer = csv.writer(f)
            csv_writer.writerow(["时间","滚转角（全局）"])
            for i in range(0,len(X)):
                csv_writer.writerow([X[i].strftime("%H:%M:%S"),Y[i]])
        self.success()    
    
    '''绘制局部滚转角数据的槽函数'''
    def gunzhuan_draw_local_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(8, '滚转角')
        if bool_is_ok == False:
            return
        if self.gunzhuan_lineEdit_starttime.text() =='' or self.gunzhuan_lineEdit_endtime.text() =='':
            msg_box = QMessageBox(QMessageBox.Warning, '警告', '起始时刻和终止时刻都不能为空！')
            msg_box.exec_()
            return
        if bool_is_ok:
            X, Y = decode_data_from_txt(selected_file, '滚转角', self.gunzhuan_lineEdit_starttime.text(), self.gunzhuan_lineEdit_endtime.text())
            self.gunzhuan_ds.X_local = X
            self.gunzhuan_ds.Y_local = Y
            self.gunzhuan_ds.cal_ave_edge()
            self.gunzhuan_label_average_edge.setText(str(round(self.gunzhuan_ds.ave_edge,3))+'°')
            self.gunzhuan_canvas_local.start_static_plot('滚转角（局部）','时间（时：分：秒）','滚转角偏差（°）',X,Y)
            try:
                if self.gunzhuan_lineEdit_shangxian.text() != '' and self.gunzhuan_lineEdit_xiaxian.text() != '':
                    if self.gunzhuan_ds.ave_edge <= float(self.gunzhuan_lineEdit_shangxian.text()) and self.gunzhuan_ds.ave_edge >= float(self.gunzhuan_lineEdit_xiaxian.text()):
                        self.gunzhuan_label_jieguo.setText('符合')
                    else:
                        self.gunzhuan_label_jieguo.setText('不符合')
            except:
                msg_box = QMessageBox(QMessageBox.Warning, '警告', '上下限填写错误！')
                msg_box.exec_()
            

    '''保存局部滚转角数据到excel'''
    def gunzhuan_local_to_excel(self):
        path = self.save_to_excel()
        if path == '':
            return
        X = self.gunzhuan_ds.X_local
        Y = self.gunzhuan_ds.Y_local
        with open(path,'w',encoding='utf-8-sig',newline='') as f:
            csv_writer = csv.writer(f)
            csv_writer.writerow(["时间","滚转角（局部）"])
            for i in range(0,len(X)):
                csv_writer.writerow([X[i].strftime("%H:%M:%S"),Y[i]])
        self.success()
    
    '''清除画布及编辑框'''
    def gunzhuan_canvas_local_clear(self):
        self.gunzhuan_canvas_local.canvas_clear()
        self.gunzhuan_lineEdit_shangxian.setText('')
        self.gunzhuan_lineEdit_xiaxian.setText('')
        self.gunzhuan_lineEdit_starttime.setText('')
        self.gunzhuan_lineEdit_endtime.setText('')
        self.gunzhuan_label_average_edge.setText('')
        self.gunzhuan_label_jieguo.setText('')
        
    '''绘制全局偏航角图像的槽函数'''
    def pianhang_draw_global_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(9, '偏航角')
        if bool_is_ok:
            X, Y = decode_data_from_txt(selected_file, '偏航角')
            self.pianhang_ds.X_global = X
            self.pianhang_ds.Y_global = Y
            self.pianhang_canvas_global.start_static_plot('偏航角（全局）','时间（时：分：秒）','偏航角（°）',X,Y)
    
    '''保存全局偏航角数据到excel'''
    def pianhang_global_to_excel(self):
        path = self.save_to_excel()
        if path == '':
            return
        X = self.pianhang_ds.X_global
        Y = self.pianhang_ds.Y_global
        with open(path,'w',encoding='utf-8-sig',newline='') as f:
            csv_writer = csv.writer(f)
            csv_writer.writerow(["时间","偏航角（全局）"])
            for i in range(0,len(X)):
                csv_writer.writerow([X[i].strftime("%H:%M:%S"),Y[i]])
        self.success()    
    
    '''绘制局部偏航角数据的槽函数'''
    def pianhang_draw_local_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(9, '偏航角')
        if bool_is_ok == False:
            return
        if self.pianhang_lineEdit_starttime.text() =='' or self.pianhang_lineEdit_endtime.text() =='':
            msg_box = QMessageBox(QMessageBox.Warning, '警告', '起始时刻和终止时刻都不能为空！')
            msg_box.exec_()
            return
        if bool_is_ok:
            X, Y = decode_data_from_txt(selected_file, '偏航角', self.pianhang_lineEdit_starttime.text(), self.pianhang_lineEdit_endtime.text())
            self.pianhang_ds.X_local = X
            self.pianhang_ds.Y_local = Y
            self.pianhang_ds.cal_ave_edge()
            self.pianhang_label_average_edge.setText(str(round(self.pianhang_ds.ave_edge,3))+'°')
            self.pianhang_canvas_local.start_static_plot('偏航角（局部）','时间（时：分：秒）','偏航角偏差（°）',X,Y)
            try:
                if self.pianhang_lineEdit_shangxian.text() != '' and self.pianhang_lineEdit_xiaxian.text() != '':
                    if self.pianhang_ds.ave_edge <= float(self.pianhang_lineEdit_shangxian.text()) and self.pianhang_ds.ave_edge >= float(self.pianhang_lineEdit_xiaxian.text()):
                        self.pianhang_label_jieguo.setText('符合')
                    else:
                        self.pianhang_label_jieguo.setText('不符合')
            except:
                msg_box = QMessageBox(QMessageBox.Warning, '警告', '上下限填写错误！')
                msg_box.exec_()
            
                
    '''保存局部偏航角数据到excel'''
    def pianhang_local_to_excel(self):
        path = self.save_to_excel()
        if path == '':
            return
        X = self.pianhang_ds.X_local
        Y = self.pianhang_ds.Y_local
        with open(path,'w',encoding='utf-8-sig',newline='') as f:
            csv_writer = csv.writer(f)
            csv_writer.writerow(["时间","偏航角（局部）"])
            for i in range(0,len(X)):
                csv_writer.writerow([X[i].strftime("%H:%M:%S"),Y[i]])
        self.success()
    
    '''清除画布及编辑框'''
    def pianhang_canvas_local_clear(self):
        self.pianhang_canvas_local.canvas_clear()
        self.pianhang_lineEdit_shangxian.setText('')
        self.pianhang_lineEdit_xiaxian.setText('')
        self.pianhang_lineEdit_starttime.setText('')
        self.pianhang_lineEdit_endtime.setText('')
        self.pianhang_label_average_edge.setText('')
        self.pianhang_label_jieguo.setText('')
        
    '''绘制全局航迹垂直精度图像的槽函数'''
    def v_trace_draw_global_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(6, '航迹垂直精度')
        if bool_is_ok:
            X, Y = decode_data_from_txt(selected_file, '航迹垂直精度')
            self.v_trace_ds.X_global = X
            self.v_trace_ds.Y_global = Y
            self.v_trace_canvas_global.start_static_plot('全局高度','时间（时：分：秒）','高度（米）',X,Y)
    
    '''绘制局部航迹垂直精度图像的槽函数'''
    def v_trace_draw_local_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(6, '航迹垂直精度')
        if bool_is_ok == False:
            return
        if self.v_trace_lineEdit_starttime.text() =='' or self.v_trace_lineEdit_endtime.text() =='':
            msg_box = QMessageBox(QMessageBox.Warning, '警告', '起始时刻和终止时刻都不能为空！')
            msg_box.exec_()
            return
        if self.v_trace_lineEdit_pre_height.text() == '':
            msg_box = QMessageBox(QMessageBox.Warning, '警告', '飞行高度不能为空！')
            msg_box.exec_()
            return
        if bool_is_ok:
            self.v_trace_ds.pre_height = float(self.v_trace_lineEdit_pre_height.text())    # 飞行高度
            X, Y = decode_data_from_txt(selected_file, '航迹垂直精度', self.v_trace_lineEdit_starttime.text(), self.v_trace_lineEdit_endtime.text(), self.v_trace_ds.pre_height)
            self.v_trace_ds.X_local = X
            self.v_trace_ds.Y_local = Y
            self.v_trace_ds.cal_max_diff()
            self.v_trace_label_max_diff.setText(str(round(self.v_trace_ds.max_diff,3))+'米')
            self.v_trace_canvas_local.start_static_plot('航迹垂直精度（局部）','时间（时：分：秒）','航迹垂直误差（米）',X,Y)
            try:
                if self.v_trace_lineEdit_shangxian.text() != '' and self.v_trace_lineEdit_xiaxian.text() != '':
                    if self.v_trace_ds.max_diff <= float(self.v_trace_lineEdit_shangxian.text()) and self.v_trace_ds.max_diff >= float(self.v_trace_lineEdit_xiaxian.text()):
                        self.v_trace_label_jieguo.setText('符合')
                    else:
                        self.v_trace_label_jieguo.setText('不符合')
            except:
                msg_box = QMessageBox(QMessageBox.Warning, '警告', '上下限填写错误！')
                msg_box.exec_()
            
    '''保存局部航迹垂直精度数据到excel'''
    def v_trace_local_to_excel(self):
        path = self.save_to_excel()
        if path == '':
            return
        X = self.v_trace_ds.X_local
        Y = self.v_trace_ds.Y_local
        with open(path,'w',encoding='utf-8-sig',newline='') as f:
            csv_writer = csv.writer(f)
            csv_writer.writerow(["时间","航迹垂直精度（误差）"])
            for i in range(0,len(X)):
                csv_writer.writerow([X[i].strftime("%H:%M:%S"),Y[i]])
        self.success()
        
    '''清除画布及编辑框'''
    def v_trace_canvas_local_clear(self):
        self.v_trace_canvas_local.canvas_clear()
        self.v_trace_lineEdit_shangxian.setText('')
        self.v_trace_lineEdit_xiaxian.setText('')
        self.v_trace_lineEdit_pre_height.setText('')
        self.v_trace_lineEdit_starttime.setText('')
        self.v_trace_lineEdit_endtime.setText('')
        self.v_trace_label_max_diff.setText('')
        self.v_trace_label_jieguo.setText('')
        
    '''绘制全局航迹水平精度图像的槽函数'''
    def h_trace_draw_global_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(5, '航迹水平精度')
        if bool_is_ok:
            X, Y = decode_data_from_txt(selected_file, '航迹水平精度')
            self.h_trace_ds.X_global = X
            self.h_trace_ds.Y_global = Y
            self.h_trace_canvas_global.start_static_plot('全局水平悬停图','时间（时：分：秒）','水平悬停差（米）',X,Y)
    
    '''绘制局部航迹水平精度图像的槽函数'''
    def h_trace_draw_local_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(5, '航迹水平精度')
        if bool_is_ok == False:
            return
        if self.h_trace_lineEdit_starttime.text() =='' or self.h_trace_lineEdit_endtime.text() =='':
            msg_box = QMessageBox(QMessageBox.Warning, '警告', '起始时刻和终止时刻都不能为空！')
            msg_box.exec_()
            return
        if bool_is_ok:
            X, Y = decode_data_from_txt(selected_file, '航迹水平精度', self.h_trace_lineEdit_starttime.text(), self.h_trace_lineEdit_endtime.text())
            self.h_trace_ds.X_local = X
            self.h_trace_ds.Y_local = Y
            self.h_trace_ds.cal_max_diff()
            self.h_trace_label_max_diff.setText(str(round(self.h_trace_ds.max_diff,3))+'米')
            self.h_trace_canvas_local.start_number_plot('航迹图（水平）','X方向（米）','Y方向（米）',X,Y)
            try:
                if self.h_trace_lineEdit_shangxian.text() != '' and self.h_trace_lineEdit_xiaxian.text() != '':
                    if self.h_trace_ds.max_diff <= float(self.h_trace_lineEdit_shangxian.text()) and self.h_trace_ds.max_diff >= float(self.h_trace_lineEdit_xiaxian.text()):
                        self.h_trace_label_jieguo.setText('符合')
                    else:
                        self.h_trace_label_jieguo.setText('不符合')
            except:
                msg_box = QMessageBox(QMessageBox.Warning, '警告', '上下限填写错误！')
                msg_box.exec_()
                     
    '''保存局部航迹水平精度数据到excel'''
    def h_trace_local_to_excel(self):
        path = self.save_to_excel()
        if path == '':
            return
        X = self.h_trace_ds.X_local
        Y = self.h_trace_ds.Y_local
        with open(path,'w',encoding='utf-8-sig',newline='') as f:
            csv_writer = csv.writer(f)
            csv_writer.writerow(["X轴","Y轴"])
            for i in range(0,len(X)):
                csv_writer.writerow([X[i],Y[i]])
        self.success()
        
    '''清除画布及编辑框'''
    def h_trace_canvas_local_clear(self):
        self.h_trace_canvas_local.canvas_clear()
        self.h_trace_lineEdit_shangxian.setText('')
        self.h_trace_lineEdit_xiaxian.setText('')
        self.h_trace_lineEdit_starttime.setText('')
        self.h_trace_lineEdit_endtime.setText('')
        self.h_trace_label_max_diff.setText('')
        self.h_trace_label_jieguo.setText('')
        
    '''绘制全局航迹水平精度(输入起终点经纬度)图像的槽函数'''
    def h_trace2_draw_global_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(5, '航迹水平精度')
        if bool_is_ok:
            X, Y = decode_data_from_txt(selected_file, '航迹水平精度2')
            self.h_trace2_ds.X_global = X
            self.h_trace2_ds.Y_global = Y
            self.h_trace2_canvas_global.start_h_trace_plot_global('全局水平航迹图','X（米）','Y（米）',X,Y)
    
    '''绘制局部航迹水平精度(输入起终点经纬度)图像的槽函数'''
    def h_trace2_draw_local_function(self):
        # 先获取需要绘制的文件名
        bool_is_ok, selected_file = self.is_checked_OK(5, '航迹水平精度')
        if bool_is_ok == False:
            return
        if self.h_trace2_lineEdit_starttime.text() =='' or self.h_trace2_lineEdit_endtime.text() =='':
            msg_box = QMessageBox(QMessageBox.Warning, '警告', '起始时刻和终止时刻都不能为空！')
            msg_box.exec_()
            return
        if bool_is_ok:
            X, Y, OB, OA = decode_data_from_txt(selected_file, '航迹水平精度2', start_time=self.h_trace2_lineEdit_starttime.text(), end_time=self.h_trace2_lineEdit_endtime.text(),start_jd_str=self.h_trace2_lineEdit_start_jd.text(),start_wd_str=self.h_trace2_lineEdit_start_wd.text(),end_jd_str=self.h_trace2_lineEdit_end_jd.text(),end_wd_str=self.h_trace2_lineEdit_end_wd.text())
            self.h_trace2_ds.X_local = X
            self.h_trace2_ds.Y_local = Y
            self.h_trace2_ds.cal_max_diff(OB,OA)
            self.h_trace2_label_max_diff.setText(str(round(self.h_trace2_ds.max_diff,3))+'米')
            self.h_trace2_canvas_local.start_h_trace_plot_local('航迹图（水平）','X方向（米）','Y方向（米）',X,Y,OB,OA)
            try:
                if self.h_trace2_lineEdit_shangxian.text() != '' and self.h_trace2_lineEdit_xiaxian.text() != '':
                    if self.h_trace2_ds.max_diff <= float(self.h_trace2_lineEdit_shangxian.text()) and self.h_trace2_ds.max_diff >= float(self.h_trace2_lineEdit_xiaxian.text()):
                        self.h_trace2_label_jieguo.setText('符合')
                    else:
                        self.h_trace2_label_jieguo.setText('不符合')
            except:
                msg_box = QMessageBox(QMessageBox.Warning, '警告', '上下限填写错误！')
                msg_box.exec_()
        
    '''保存局部航迹水平精度数据到excel'''
    def h_trace2_local_to_excel(self):
        path = self.save_to_excel()
        if path == '':
            return
        X = self.h_trace2_ds.X_local
        Y = self.h_trace2_ds.Y_local
        with open(path,'w',encoding='utf-8-sig',newline='') as f:
            csv_writer = csv.writer(f)
            csv_writer.writerow(["X轴","Y轴"])
            for i in range(0,len(X)):
                csv_writer.writerow([X[i],Y[i]])
        self.success()
        
    '''清除画布及编辑框'''
    def h_trace2_canvas_local_clear(self):
        self.h_trace2_canvas_local.canvas_clear()
        self.h_trace2_lineEdit_start_jd.setText('')
        self.h_trace2_lineEdit_start_wd.setText('')
        self.h_trace2_lineEdit_end_jd.setText('')
        self.h_trace2_lineEdit_end_wd.setText('')
        self.h_trace2_lineEdit_shangxian.setText('')
        self.h_trace2_lineEdit_xiaxian.setText('')
        self.h_trace2_lineEdit_starttime.setText('')
        self.h_trace2_lineEdit_endtime.setText('')
        self.h_trace2_label_max_diff.setText('')
        self.h_trace2_label_jieguo.setText('')
        
    '''生成报告的槽函数'''
    def report_generate_report(self):
        fileName_choose, filetype = QFileDialog.getSaveFileName(self,  
                                    "Word报告保存",  
                                    self.cwd, # 起始路径 
                                    "Word Files (*.docx)")
        if fileName_choose == '':
            return
        # 开始生成报告
        document = Document()
        # 标题
        style1 = document.styles.add_style('style1', WD_STYLE_TYPE.PARAGRAPH)
        style1.font.name = u'宋体'
        style1.font.size = Pt(18)
        style1._element.rPr.rFonts.set(qn('w:eastAsia'), u'宋体')
        p1 = document.add_paragraph(u"无人机飞行性能测试报告", style=style1)
        p1.paragraph_format.alignment = WD_ALIGN_PARAGRAPH.CENTER
        # 测试条件
        style2 = document.styles.add_style('style2', WD_STYLE_TYPE.PARAGRAPH)
        style2.font.name = u'宋体'
        style2.font.size = Pt(12)
        style2._element.rPr.rFonts.set(qn('w:eastAsia'), u'宋体')
        p2 = document.add_paragraph('任务号：' + self.report_lineEdit_renwuhao.text(), style=style2)
        p2.add_run('\n' + '测试人员：' + self.report_lineEdit_renyuan.text())
        p2.add_run('\n' + '测试日期：' + self.report_lineEdit_riqi.text())
        p2.add_run('\n' + '产品名称：' + self.report_lineEdit_mingcheng.text())
        p2.add_run('\n' + '产品型号：' + self.report_lineEdit_xinghao.text())
        p2.add_run('\n' + '产品厂家：' + self.report_lineEdit_changjia.text())
        p2.add_run('\n' + '测试地点：' + self.report_lineEdit_didian.text())
        # 表格
        table = document.add_table(rows=14, cols=5)
        hdr_cells = table.rows[0].cells
        hdr_cells[0].text = '序号'
        hdr_cells[1].text = '检测项目'
        hdr_cells[2].text = '具体说明'
        hdr_cells[3].text = '检测结果'
        hdr_cells[4].text = '是否符合'
        
        cells = table.rows[1].cells
        cells[0].text = '1'
        cells[1].text = '高度'
        cells[2].text = '（m）\n'+'上限：'+self.height_lineEdit_shangxian.text()+'\n下限：'+self.height_lineEdit_xiaxian.text()
        cells[3].text = self.height_label_average_height.text()
        cells[4].text = self.height_label_jieguo.text()
        
        table.cell(2,0).merge(table.cell(4,0))
        table.cell(4,0).text = '2'
        table.cell(2,1).merge(table.cell(4,1))
        table.cell(4,1).text = '平飞速度'
        table.cell(2,2).text = '往（m/s）'
        table.cell(3,2).text = '返（m/s）'
        table.cell(4,2).text = '均值（m/s）\n'+'上限：'+self.h_speed_lineEdit_shangxian.text()+'\n下限：'+self.h_speed_lineEdit_xiaxian.text()
        table.cell(2,3).text = self.h_speed_label_wang.text()
        table.cell(3,3).text = self.h_speed_label_fan.text()
        table.cell(4,3).text = self.h_speed_label_all.text()
        table.cell(2,4).text = '--'
        table.cell(3,4).text = '--'
        table.cell(4,4).text = self.h_speed_label_jieguo_global.text()
        
        cells = table.rows[5].cells
        cells[0].text = '3'
        cells[1].text = '上升速度'
        cells[2].text = '（m/s）\n'+'上限：'+self.v_speed_lineEdit_shang_shangxian.text()+'\n下限：'+self.v_speed_lineEdit_shang_xiaxian.text()
        cells[3].text = self.v_speed_label_shang.text()
        cells[4].text = self.v_speed_label_jieguo_shang.text()
        
        cells = table.rows[6].cells
        cells[0].text = '4'
        cells[1].text = '下降速度'
        cells[2].text = '（m/s）\n'+'上限：'+self.v_speed_lineEdit_xia_shangxian.text()+'\n下限：'+self.v_speed_lineEdit_xia_xiaxian.text()
        cells[3].text = self.v_speed_label_xia.text()
        cells[4].text = self.v_speed_label_jieguo_xia.text()
        
        table.cell(7,0).merge(table.cell(9,0))
        table.cell(9,0).text = '5'
        table.cell(7,1).merge(table.cell(9,1))
        table.cell(9,1).text = '姿态精度'
        table.cell(7,2).text = '滚转角（°）\n'+'上限：'+self.gunzhuan_lineEdit_shangxian.text()+'\n下限：'+self.gunzhuan_lineEdit_xiaxian.text()
        table.cell(8,2).text = '偏航角（°）\n'+'上限：'+self.pianhang_lineEdit_shangxian.text()+'\n下限：'+self.pianhang_lineEdit_xiaxian.text()
        table.cell(9,2).text = '俯仰角（°）\n'+'上限：'+self.fuyang_lineEdit_shangxian.text()+'\n下限：'+self.fuyang_lineEdit_xiaxian.text()
        table.cell(7,3).text = self.gunzhuan_label_average_edge.text()
        table.cell(8,3).text = self.pianhang_label_average_edge.text()
        table.cell(9,3).text = self.fuyang_label_average_edge.text()
        table.cell(7,4).text = self.gunzhuan_label_jieguo.text()
        table.cell(8,4).text = self.pianhang_label_jieguo.text()
        table.cell(9,4).text = self.fuyang_label_jieguo.text()
        
        table.cell(10,0).merge(table.cell(11,0))
        table.cell(11,0).text = '6'
        table.cell(10,1).merge(table.cell(11,1))
        table.cell(11,1).text = '悬停精度'
        table.cell(10,2).text = '水平（m）\n'+'上限：'+self.h_stop_lineEdit_shangxian.text()+'\n下限：'+self.h_stop_lineEdit_xiaxian.text()
        table.cell(11,2).text = '垂直（m）\n'+'上限：'+self.v_stop_lineEdit_shangxian.text()+'\n下限：'+self.v_stop_lineEdit_xiaxian.text()
        table.cell(10,3).text = self.h_stop_label_max_diff.text()
        table.cell(11,3).text = self.v_stop_label_max_diff.text()
        table.cell(10,4).text = self.h_stop_label_jieguo.text()
        table.cell(11,4).text = self.v_stop_label_jieguo.text()
        
        table.cell(12,0).merge(table.cell(13,0))
        table.cell(13,0).text = '7'
        table.cell(12,1).merge(table.cell(13,1))
        table.cell(13,1).text = '航迹精度'
        table.cell(13,2).text = '垂直（m）\n'+'上限：'+self.v_trace_lineEdit_shangxian.text()+'\n下限：'+self.v_trace_lineEdit_xiaxian.text()
        if self.report_comboBox.currentText() == '航迹水平偏差':
            table.cell(12,2).text = '水平（m）\n'+'上限：'+self.h_trace_lineEdit_shangxian.text()+'\n下限：'+self.h_trace_lineEdit_xiaxian.text()
            table.cell(12,3).text = self.h_trace_label_max_diff.text()
            table.cell(12,4).text = self.h_trace_label_jieguo.text()
        elif self.report_comboBox.currentText() == '航迹水平偏差（输入起终点经纬度）':
            table.cell(12,2).text = '水平（m）\n'+'上限：'+self.h_trace2_lineEdit_shangxian.text()+'\n下限：'+self.h_trace2_lineEdit_xiaxian.text()
            table.cell(12,3).text = self.h_trace2_label_max_diff.text()
            table.cell(12,4).text = self.h_trace2_label_jieguo.text()
        table.cell(13,3).text = self.v_trace_label_max_diff.text()
        table.cell(13,4).text = self.v_trace_label_jieguo.text()
        
        
        table.style='Table Grid'
        table.style.font.name = u'宋体'
        table.style.font.size = Pt(12)
        table.style._element.rPr.rFonts.set(qn('w:eastAsia'), u'宋体')
        for i in range(14):
            for j in range(5):
                # 水平对齐
                table.cell(i,j).paragraphs[0].paragraph_format.alignment=WD_ALIGN_PARAGRAPH.CENTER
                # 垂直对齐
                table.cell(i,j).vertical_alignment = WD_ALIGN_VERTICAL.CENTER
        for i in range(14):
            tr = table.rows[i]._tr 
            trPr = tr.get_or_add_trPr() 
            trHeight = OxmlElement('w:trHeight') 
            trHeight.set(qn2('w:val'), "650") 
            trHeight.set(qn2('w:hRule'), "atLeast") 
            trPr.append(trHeight) 
        
        # 插入图片
        p3 = document.add_paragraph()
         #图片居中设置
        p3.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER     
        run = p3.add_run("")
        # 创建缓存目录
        if not os.path.exists('temp'):
            os.mkdir('temp')
        self.height_canvas_local.fig.savefig('temp/1.png')
        run.add_picture('temp/1.png', width=Inches(6))
        self.h_speed_canvas_wang.fig.savefig('temp/2.png')
        run.add_picture('temp/2.png', width=Inches(6))
        self.h_speed_canvas_fan.fig.savefig('temp/3.png')
        run.add_picture('temp/3.png', width=Inches(6))
        self.v_speed_canvas_shang.fig.savefig('temp/4.png')
        run.add_picture('temp/4.png', width=Inches(6))
        self.v_speed_canvas_xia.fig.savefig('temp/5.png')
        run.add_picture('temp/5.png', width=Inches(6))
        self.gunzhuan_canvas_local.fig.savefig('temp/6.png')
        run.add_picture('temp/6.png', width=Inches(6))
        self.pianhang_canvas_local.fig.savefig('temp/7.png')
        run.add_picture('temp/7.png', width=Inches(6))
        self.fuyang_canvas_local.fig.savefig('temp/8.png')
        run.add_picture('temp/8.png', width=Inches(6))
        self.h_stop_canvas_local.fig.savefig('temp/9.png')
        run.add_picture('temp/9.png', width=Inches(6))
        self.v_stop_canvas_local.fig.savefig('temp/10.png')
        run.add_picture('temp/10.png', width=Inches(6))
        if self.report_comboBox.currentText() == '航迹水平偏差':
            self.h_trace_canvas_local.fig.savefig('temp/11.png')
            run.add_picture('temp/11.png', width=Inches(6))
        elif self.report_comboBox.currentText() == '航迹水平偏差（输入起终点经纬度）':
            self.h_trace2_canvas_local.fig.savefig('temp/11.png')
            run.add_picture('temp/11.png', width=Inches(6))
        self.v_trace_canvas_local.fig.savefig('temp/12.png')
        run.add_picture('temp/12.png', width=Inches(6))
        shutil.rmtree('temp')
        
        document.save(fileName_choose)
        self.success()

    '''导出配置'''       
    def output_function(self):
        dir_choose = QFileDialog.getExistingDirectory(self,  
                                    "选取保存配置的文件夹",  
                                    self.cwd) # 起始路径
        if dir_choose == "":
            return
        save_dir = dir_choose + '/配置' + str(datetime.datetime.now())[0:19].replace(':','-').replace('-','')    # 保存配置文件的目录
        if not os.path.exists(save_dir):    # 创建目录
            os.mkdir(save_dir)
        if len(self.files) == 0:
            msg_box = QMessageBox(QMessageBox.Warning, '警告', '目前无配置需要保存！')
            msg_box.exec_()
        with open(os.path.join(save_dir,"--files.txt"), "w") as f:
            f.write(str(len(self.files))+'\n')
            for file in self.files:
                f.write(file.split('/')[-1] + '\n')
                shutil.copy(file,save_dir+'/'+file.split('/')[-1])
        with open(os.path.join(save_dir,"--check_states.txt"), "w") as f:
            f.write(str(len(self.files))+'\n')
            for i,file in enumerate(self.files):
                for j in range(0,10):
                    f.write(str(self.tableWidget_select.item(i,j).checkState())+' ')
                f.write('\n')
        with open(os.path.join(save_dir,"--高度.txt"), "w") as f:
            f.write(self.height_lineEdit_starttime.text()+'\n')
            f.write(self.height_lineEdit_endtime.text()+'\n')
            f.write(self.height_lineEdit_shangxian.text()+'\n')
            f.write(self.height_lineEdit_xiaxian.text()+'\n')
        with open(os.path.join(save_dir,"--水平速度.txt"), "w") as f:
            f.write(self.h_speed_lineEdit_starttime_wang.text()+'\n')
            f.write(self.h_speed_lineEdit_endtime_wang.text()+'\n')
            f.write(self.h_speed_lineEdit_starttime_fan.text()+'\n')
            f.write(self.h_speed_lineEdit_endtime_fan.text()+'\n')
            f.write(self.h_speed_lineEdit_shangxian.text()+'\n')
            f.write(self.h_speed_lineEdit_xiaxian.text()+'\n')
        with open(os.path.join(save_dir,"--垂直速度.txt"), "w") as f:
            f.write(self.v_speed_lineEdit_starttime_shang.text()+'\n')
            f.write(self.v_speed_lineEdit_endtime_shang.text()+'\n')
            f.write(self.v_speed_lineEdit_starttime_xia.text()+'\n')
            f.write(self.v_speed_lineEdit_endtime_xia.text()+'\n')
            f.write(self.v_speed_lineEdit_shang_shangxian.text()+'\n')
            f.write(self.v_speed_lineEdit_shang_xiaxian.text()+'\n')
            f.write(self.v_speed_lineEdit_xia_shangxian.text()+'\n')
            f.write(self.v_speed_lineEdit_xia_xiaxian.text()+'\n')
        with open(os.path.join(save_dir,"--水平悬停.txt"), "w") as f:
            f.write(self.h_stop_lineEdit_starttime.text()+'\n')
            f.write(self.h_stop_lineEdit_endtime.text()+'\n')
            f.write(self.h_stop_lineEdit_shangxian.text()+'\n')
            f.write(self.h_stop_lineEdit_xiaxian.text()+'\n')
        with open(os.path.join(save_dir,"--垂直悬停.txt"), "w") as f:
            f.write(self.v_stop_lineEdit_starttime.text()+'\n')
            f.write(self.v_stop_lineEdit_endtime.text()+'\n')
            f.write(self.v_stop_lineEdit_shangxian.text()+'\n')
            f.write(self.v_stop_lineEdit_xiaxian.text()+'\n')
        with open(os.path.join(save_dir,"--航迹水平偏差.txt"), "w") as f:
            f.write(self.h_trace_lineEdit_starttime.text()+'\n')
            f.write(self.h_trace_lineEdit_endtime.text()+'\n')
            f.write(self.h_trace_lineEdit_shangxian.text()+'\n')
            f.write(self.h_trace_lineEdit_xiaxian.text()+'\n')
        with open(os.path.join(save_dir,"--航迹水平偏差2.txt"), "w") as f:
            f.write(self.h_trace2_lineEdit_starttime.text()+'\n')
            f.write(self.h_trace2_lineEdit_endtime.text()+'\n')
            f.write(self.h_trace2_lineEdit_shangxian.text()+'\n')
            f.write(self.h_trace2_lineEdit_xiaxian.text()+'\n')
            f.write(self.h_trace2_lineEdit_start_jd.text()+'\n')
            f.write(self.h_trace2_lineEdit_start_wd.text()+'\n')
            f.write(self.h_trace2_lineEdit_end_jd.text()+'\n')
            f.write(self.h_trace2_lineEdit_end_wd.text()+'\n')
        with open(os.path.join(save_dir,"--航迹垂直偏差.txt"), "w") as f:
            f.write(self.v_trace_lineEdit_starttime.text()+'\n')
            f.write(self.v_trace_lineEdit_endtime.text()+'\n')
            f.write(self.v_trace_lineEdit_pre_height.text()+'\n')
            f.write(self.v_trace_lineEdit_shangxian.text()+'\n')
            f.write(self.v_trace_lineEdit_xiaxian.text()+'\n')
        with open(os.path.join(save_dir,"--俯仰角.txt"), "w") as f:
            f.write(self.fuyang_lineEdit_starttime.text()+'\n')
            f.write(self.fuyang_lineEdit_endtime.text()+'\n')
            f.write(self.fuyang_lineEdit_shangxian.text()+'\n')
            f.write(self.fuyang_lineEdit_xiaxian.text()+'\n')
        with open(os.path.join(save_dir,"--滚转角.txt"), "w") as f:
            f.write(self.gunzhuan_lineEdit_starttime.text()+'\n')
            f.write(self.gunzhuan_lineEdit_endtime.text()+'\n')
            f.write(self.gunzhuan_lineEdit_shangxian.text()+'\n')
            f.write(self.gunzhuan_lineEdit_xiaxian.text()+'\n')
        with open(os.path.join(save_dir,"--偏航角.txt"), "w") as f:
            f.write(self.pianhang_lineEdit_starttime.text()+'\n')
            f.write(self.pianhang_lineEdit_endtime.text()+'\n')
            f.write(self.pianhang_lineEdit_shangxian.text()+'\n')
            f.write(self.pianhang_lineEdit_xiaxian.text()+'\n')
        with open(os.path.join(save_dir,"--word报告.txt"), "w") as f:
            f.write(self.report_lineEdit_renwuhao.text()+'\n')
            f.write(self.report_lineEdit_renyuan.text()+'\n')
            f.write(self.report_lineEdit_riqi.text()+'\n')
            f.write(self.report_lineEdit_mingcheng.text()+'\n')
            f.write(self.report_lineEdit_xinghao.text()+'\n')
            f.write(self.report_lineEdit_changjia.text()+'\n')
            f.write(self.report_lineEdit_didian.text()+'\n')
            f.write(self.report_comboBox.currentText()+'\n')
        
    '''导入配置'''
    def input_function(self):
        dir_choose = QFileDialog.getExistingDirectory(self,  
                                    "选取导入配置的文件夹",  
                                    self.cwd) # 起始路径
        if dir_choose == "":
            return
        if len(self.files) > 0:
            msg_box = QMessageBox(QMessageBox.Warning, '警告', '已选取文件，无法导入配置，请重启程序！')
            msg_box.exec_()
        # 导入文件名
        with open(os.path.join(dir_choose, '--files.txt'), 'r') as f:
            files_num = int(f.readline())
            for i in range(files_num):
                self.files.append(dir_choose+'/'+f.readline()[0:-1])
        self.tableWidget_select.setRowCount(len(self.files))    # 要先设置行数，才能显示行
        self.tableWidget_select.setVerticalHeaderLabels(self.files)    # 设置行
        # 导入状态
        check_states = []
        with open(os.path.join(dir_choose, '--check_states.txt'), 'r') as f:
            files_num = int(f.readline())
            for i in range(files_num):
                cs = f.readline().split(' ')[0:-1]
                check_states.append(cs)
                for j in range(0, 10):
                    check = QtWidgets.QTableWidgetItem()
                    if cs[j] == '0':
                        check.setCheckState(QtCore.Qt.Unchecked)
                    elif cs[j] == '2':
                        check.setCheckState(QtCore.Qt.Checked)
                    self.tableWidget_select.setItem(i, j, check)
        # 所有tab界面
        with open(os.path.join(dir_choose, '--word报告.txt'), 'r') as f:
            self.report_lineEdit_renwuhao.setText(f.readline()[0:-1])
            self.report_lineEdit_renyuan.setText(f.readline()[0:-1])
            self.report_lineEdit_riqi.setText(f.readline()[0:-1])
            self.report_lineEdit_mingcheng.setText(f.readline()[0:-1])
            self.report_lineEdit_xinghao.setText(f.readline()[0:-1])
            self.report_lineEdit_changjia.setText(f.readline()[0:-1])
            self.report_lineEdit_didian.setText(f.readline()[0:-1])
            text = f.readline()[0:-1]
            if text == '航迹水平偏差（输入起终点经纬度）':
                self.report_comboBox.setCurrentIndex(0)
            else:
                self.report_comboBox.setCurrentIndex(1)
        with open(os.path.join(dir_choose, '--高度.txt'), 'r') as f:
            for j in range(len(self.files)):
                if check_states[j][0] == '2':
                    self.height_draw_global_function()
                    self.height_lineEdit_starttime.setText(f.readline()[0:-1])
                    self.height_lineEdit_endtime.setText(f.readline()[0:-1])
                    self.height_lineEdit_shangxian.setText(f.readline()[0:-1])
                    self.height_lineEdit_xiaxian.setText(f.readline()[0:-1])
                    try:
                        self.height_draw_local_function()
                    except:
                        print('无上下限')
                    break
        with open(os.path.join(dir_choose, '--水平速度.txt'), 'r') as f:
            for j in range(len(self.files)):
                if check_states[j][1] == '2':
                    self.h_speed_draw_global_function()
                    self.h_speed_lineEdit_starttime_wang.setText(f.readline()[0:-1])
                    self.h_speed_lineEdit_endtime_wang.setText(f.readline()[0:-1])
                    self.h_speed_lineEdit_starttime_fan.setText(f.readline()[0:-1])
                    self.h_speed_lineEdit_endtime_fan.setText(f.readline()[0:-1])
                    self.h_speed_lineEdit_shangxian.setText(f.readline()[0:-1])
                    self.h_speed_lineEdit_xiaxian.setText(f.readline()[0:-1])
                    try:
                        self.h_speed_draw_wang_function()
                    except:
                        print('无上下限')
                    try:
                        self.h_speed_draw_fan_function()
                    except:
                        print('无上下限')
                    self.h_speed_average_all_function()
                    break
        with open(os.path.join(dir_choose, '--垂直速度.txt'), 'r') as f:
            for j in range(len(self.files)):
                if check_states[j][2] == '2':
                    self.v_speed_draw_global_function()
                    self.v_speed_lineEdit_starttime_shang.setText(f.readline()[0:-1])
                    self.v_speed_lineEdit_endtime_shang.setText(f.readline()[0:-1])
                    self.v_speed_lineEdit_starttime_xia.setText(f.readline()[0:-1])
                    self.v_speed_lineEdit_endtime_xia.setText(f.readline()[0:-1])
                    self.v_speed_lineEdit_shang_shangxian.setText(f.readline()[0:-1])
                    self.v_speed_lineEdit_shang_xiaxian.setText(f.readline()[0:-1])
                    self.v_speed_lineEdit_xia_shangxian.setText(f.readline()[0:-1])
                    self.v_speed_lineEdit_xia_xiaxian.setText(f.readline()[0:-1])
                    try:
                        self.v_speed_draw_shang_function()
                    except:
                        print('无上下限')
                    try:
                        self.v_speed_draw_xia_function()
                    except:
                        print('无上下限')
                    break
        with open(os.path.join(dir_choose, '--水平悬停.txt'), 'r') as f:
            for j in range(len(self.files)):
                if check_states[j][3] == '2':
                    self.h_stop_draw_global_function()
                    self.h_stop_lineEdit_starttime.setText(f.readline()[0:-1])
                    self.h_stop_lineEdit_endtime.setText(f.readline()[0:-1])
                    self.h_stop_lineEdit_shangxian.setText(f.readline()[0:-1])
                    self.h_stop_lineEdit_xiaxian.setText(f.readline()[0:-1])
                    try:
                        self.h_stop_draw_local_function()
                    except:
                        print('无上下限')
                    break
        with open(os.path.join(dir_choose, '--垂直悬停.txt'), 'r') as f:
            for j in range(len(self.files)):
                if check_states[j][4] == '2':
                    self.v_stop_draw_global_function()
                    self.v_stop_lineEdit_starttime.setText(f.readline()[0:-1])
                    self.v_stop_lineEdit_endtime.setText(f.readline()[0:-1])
                    self.v_stop_lineEdit_shangxian.setText(f.readline()[0:-1])
                    self.v_stop_lineEdit_xiaxian.setText(f.readline()[0:-1])
                    try:
                       self.v_stop_draw_local_function() 
                    except:
                        print('无上下限')
                    break
        if self.report_comboBox.currentText() == '航迹水平偏差':
            with open(os.path.join(dir_choose, '--航迹水平偏差.txt'), 'r') as f:
                for j in range(len(self.files)):
                    if check_states[j][5] == '2':
                        self.h_trace_draw_global_function()
                        self.h_trace_lineEdit_starttime.setText(f.readline()[0:-1])
                        self.h_trace_lineEdit_endtime.setText(f.readline()[0:-1])
                        self.h_trace_lineEdit_shangxian.setText(f.readline()[0:-1])
                        self.h_trace_lineEdit_xiaxian.setText(f.readline()[0:-1])
                        try:
                            self.h_trace_draw_local_function()
                        except:
                            print('无上下限')
                        break
        if self.report_comboBox.currentText() == '航迹水平偏差（输入起终点经纬度）':
            with open(os.path.join(dir_choose, '--航迹水平偏差2.txt'), 'r') as f:
                for j in range(len(self.files)):
                    if check_states[j][5] == '2':
                        self.h_trace2_draw_global_function()
                        self.h_trace2_lineEdit_starttime.setText(f.readline()[0:-1])
                        self.h_trace2_lineEdit_endtime.setText(f.readline()[0:-1])
                        self.h_trace2_lineEdit_shangxian.setText(f.readline()[0:-1])
                        self.h_trace2_lineEdit_xiaxian.setText(f.readline()[0:-1])
                        self.h_trace2_lineEdit_start_jd.setText(f.readline()[0:-1])
                        self.h_trace2_lineEdit_start_wd.setText(f.readline()[0:-1])
                        self.h_trace2_lineEdit_end_jd.setText(f.readline()[0:-1])
                        self.h_trace2_lineEdit_end_wd.setText(f.readline()[0:-1])
                        try:
                            self.h_trace2_draw_local_function()
                        except:
                            print('无上下限')
                        break
        with open(os.path.join(dir_choose, '--航迹垂直偏差.txt'), 'r') as f:
            for j in range(len(self.files)):
                if check_states[j][6] == '2':
                    self.v_trace_draw_global_function()
                    self.v_trace_lineEdit_starttime.setText(f.readline()[0:-1])
                    self.v_trace_lineEdit_endtime.setText(f.readline()[0:-1])
                    self.v_trace_lineEdit_pre_height.setText(f.readline()[0:-1])
                    self.v_trace_lineEdit_shangxian.setText(f.readline()[0:-1])
                    self.v_trace_lineEdit_xiaxian.setText(f.readline()[0:-1])
                    try:
                       self.v_trace_draw_local_function() 
                    except:
                        print('无上下限')
                    break
        with open(os.path.join(dir_choose, '--俯仰角.txt'), 'r') as f:
            for j in range(len(self.files)):
                if check_states[j][7] == '2':
                    self.fuyang_draw_global_function()
                    self.fuyang_lineEdit_starttime.setText(f.readline()[0:-1])
                    self.fuyang_lineEdit_endtime.setText(f.readline()[0:-1])
                    self.fuyang_lineEdit_shangxian.setText(f.readline()[0:-1])
                    self.fuyang_lineEdit_xiaxian.setText(f.readline()[0:-1])
                    try:
                        self.fuyang_draw_local_function()
                    except:
                        print('无上下限')
                    break
        with open(os.path.join(dir_choose, '--滚转角.txt'), 'r') as f:
            for j in range(len(self.files)):
                if check_states[j][8] == '2':
                    self.gunzhuan_draw_global_function()
                    self.gunzhuan_lineEdit_starttime.setText(f.readline()[0:-1])
                    self.gunzhuan_lineEdit_endtime.setText(f.readline()[0:-1])
                    self.gunzhuan_lineEdit_shangxian.setText(f.readline()[0:-1])
                    self.gunzhuan_lineEdit_xiaxian.setText(f.readline()[0:-1])
                    try:
                        self.gunzhuan_draw_local_function()
                    except:
                        print('无上下限')
                    break
        with open(os.path.join(dir_choose, '--偏航角.txt'), 'r') as f:
            for j in range(len(self.files)):
                if check_states[j][9] == '2':
                    self.pianhang_draw_global_function()
                    self.pianhang_lineEdit_starttime.setText(f.readline()[0:-1])
                    self.pianhang_lineEdit_endtime.setText(f.readline()[0:-1])
                    self.pianhang_lineEdit_shangxian.setText(f.readline()[0:-1])
                    self.pianhang_lineEdit_xiaxian.setText(f.readline()[0:-1])
                    try:
                        self.pianhang_draw_local_function()
                    except:
                        print('无上下限')
                    break

if __name__ == "__main__":
    app = QApplication(sys.argv)
    mywin = MainWindow()
    mywin.show()
    sys.exit(app.exec_())